]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/Player.cs
Protoshow sprint.
[rbdr/super-polarity] / Super Polarity / Player.cs
index 25e66da7f668d750096c36cc0028f10237e2904a..2680a1ce4397cc83053335897662d2f45f6ba149 100644 (file)
@@ -2,6 +2,8 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
 
 namespace SuperPolarity
 {
@@ -11,11 +13,20 @@ namespace SuperPolarity
         public int Multiplier;
         public int Lives;
 
-        public Player()
+
+        SpriteFont DebugFont;
+        SuperPolarity Game;
+
+        Texture2D LifeSprite;
+
+        public Player(SuperPolarity game)
         {
             Score = 0;
             Multiplier = 1;
             Lives = 3;
+            Game = game;
+            DebugFont = Game.Content.Load<SpriteFont>("Fonts\\bigfont");
+            LifeSprite = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
         }
 
         public void AddScore(int value)
@@ -33,14 +44,38 @@ namespace SuperPolarity
             Multiplier = 1;
         }
 
-        public void Draw()
+        public void Draw(SpriteBatch spriteBatch)
         {
+            var UiColor = new Color(0, 0, 0, 200);
+            var lightColor = new Color(0, 0, 0, 128);
+            spriteBatch.DrawString(DebugFont, Score.ToString(), new Vector2(10, 10), UiColor);
+            spriteBatch.DrawString(DebugFont, "x" + Multiplier.ToString(), new Vector2(10, 30), lightColor);
 
+            var lifePosition = new Vector2(Game.GraphicsDevice.Viewport.Width - 120, 10);
+            if (Lives > 4)
+            {
+                spriteBatch.Draw(LifeSprite, lifePosition, null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
+                spriteBatch.DrawString(DebugFont, "x " + Lives.ToString(), new Vector2(lifePosition.X + 8, lifePosition.Y + 5), UiColor);
+            }
+            else
+            {
+                for (var i = 0; i < Lives; i++)
+                {
+                    spriteBatch.Draw(LifeSprite, new Vector2(lifePosition.X + (i * 28), lifePosition.Y), null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
+                }
+            }
         }
 
         public void Update()
         {
 
         }
+
+        public void Reset()
+        {
+            Score = 0;
+            Multiplier = 1;
+            Lives = 3;
+        }
     }
 }